package com.btr.service.impl;

import com.btr.entity.TblUser;
import com.btr.mapper.TblUserMapper;
import com.btr.service.ITblUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yanxi on 2018/1/16 0016.
 */
@Service
public class TblUserImpl implements ITblUserService {

    @Autowired
    private TblUserMapper tblUserMapper;

    @Override
    @Cacheable(value = "TblUser")
    public TblUser getByid(Integer id) {
        return tblUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int save(TblUser tblUser) {
        return tblUserMapper.insert(tblUser);
    }

    @Override
    @CacheEvict("TblUser")
    public int update(TblUser tblUser) {
        return tblUserMapper.updateByPrimaryKey(tblUser);
    }

    @Override
    @Cacheable("TblUser")
    public List<TblUser> getAll() {
        return tblUserMapper.selectAll();
    }
}
